namespace IAM.Interface.Model
{
    using IAM.Interface.Common;
    using IAM.Interface.Model.Interface;
    using System;
    using System.Reflection;
    using System.Text;

    [Serializable]
    public class AccountInfo : AbstractConvertObject, IConvertXml
    {
        private string _adaccount = "";
        private string _appaccount = "";
        private string _cilx500 = "";
        private string _cslaccount = "";
        private string _hriseid = "";
        private string _iamid = "";
        private string _password = "";
        private string _upi = "";

        public override object ConvertToObject()
        {
            this.HRISEID = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("HRISEID").InnerText);
            this.ADAccount = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("ADAccount").InnerText);
            this.CSLAccount = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("CSLAccount").InnerText);
            this.CILX500 = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("CILX500").InnerText);
            this.UPI = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("UPI").InnerText);
            this.AppAccount = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("AppAccount").InnerText);
            try
            {
                this.IAMID = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("IAMID").InnerText);
            }
            catch
            {
                this.IAMID = "";
            }
            try
            {
                this.Password = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("Password").InnerText);
            }
            catch
            {
                this.Password = "";
            }
            return this;
        }

        public override bool Equals(object obj)
        {
            AccountInfo ai = null;
            try
            {
                ai = (AccountInfo) obj;
            }
            catch
            {
                return false;
            }
            bool result = true;
            if (this.HRISEID != ai.HRISEID)
            {
                result = false;
            }
            else
            {
                if (this.ADAccount != ai.ADAccount)
                {
                    return false;
                }
                if (this.CSLAccount != ai.CSLAccount)
                {
                    return false;
                }
                if (this.CILX500 != ai.CILX500)
                {
                    return false;
                }
                if (this.UPI != ai.UPI)
                {
                    return false;
                }
                if (this.AppAccount != ai.AppAccount)
                {
                    result = false;
                }
                else if (this.IAMID != ai.IAMID)
                {
                    result = false;
                }
            }
            return result;
        }

        public override int GetHashCode()
        {
            int result = 1;
            PropertyInfo[] pi = base.GetType().GetProperties();
            foreach (PropertyInfo onofpi in pi)
            {
                result += onofpi.GetHashCode();
            }
            return result;
        }

        public string ADAccount
        {
            get
            {
                return this._adaccount;
            }
            set
            {
                this._adaccount = value;
            }
        }

        public string AppAccount
        {
            get
            {
                return this._appaccount;
            }
            set
            {
                this._appaccount = value;
            }
        }

        public string CILX500
        {
            get
            {
                return this._cilx500;
            }
            set
            {
                this._cilx500 = value;
            }
        }

        public string CSLAccount
        {
            get
            {
                return this._cslaccount;
            }
            set
            {
                this._cslaccount = value;
            }
        }

        public string HRISEID
        {
            get
            {
                return this._hriseid;
            }
            set
            {
                this._hriseid = value;
            }
        }

        public string IAMID
        {
            get
            {
                return this._iamid;
            }
            set
            {
                this._iamid = value;
            }
        }

        public string Password
        {
            get
            {
                return this._password;
            }
            set
            {
                this._password = value;
            }
        }

        public string UPI
        {
            get
            {
                return this._upi;
            }
            set
            {
                this._upi = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append(" <AccountInfo>");
                _xml.Append(" <HRISEID>" + EnDeCoding.Encode(this.HRISEID) + "</HRISEID>");
                _xml.Append(" <ADAccount>" + EnDeCoding.Encode(this.ADAccount) + "</ADAccount>");
                _xml.Append(" <CSLAccount>" + EnDeCoding.Encode(this.CSLAccount) + "</CSLAccount>");
                _xml.Append(" <CILX500>" + EnDeCoding.Encode(this.CILX500) + "</CILX500>");
                _xml.Append(" <UPI>" + EnDeCoding.Encode(this.UPI) + "</UPI>");
                _xml.Append(" <AppAccount>" + EnDeCoding.Encode(this.AppAccount) + "</AppAccount>");
                _xml.Append(" <IAMID>" + EnDeCoding.Encode(this.IAMID) + "</IAMID>");
                try
                {
                    _xml.Append(" <Password>" + EnDeCoding.Encode(this.Password) + "</Password>");
                }
                catch
                {
                }
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "</AccountInfo>";
            }
        }
    }
}
